/*
 * @(#)MetadataDC.java 0.0.1-SNAPSHOT
 * Copyright Group B
 */

package grupb.upf.XMLObjects.impl;

import java.io.Serializable;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;

/**
 * <p>This is the class MetadataDC and it implements the MetadataDC interface.
 * It allows us to manage the Metadata of different objects using the
 * Dublin Core standard.</p>
 *
 * @version    0.0.1-SNAPSHOT
 * @author     Group B
 */
public final class MetadataDC implements grupb.upf.XMLObjects.MetadataDC,
        Serializable {

    /**
     * The content metadata.
     */
    private Map < String, String > content =
            new Hashtable < String, String > ();
    /**
     * The intellectual metadata.
     */
    private Map < String, String > intellectual =
            new Hashtable < String, String > ();
    /**
     * The instantiation metadata.
     */
    private Map < String, String > instantiation =
            new Hashtable < String, String > ();

    /**
     * Method to set a new metadata of the category "Content".
     * @param property the name of the metadata
     * @param value the value of the metadata
     */
    @Override
    public void setContentProperty(final String property, final String value) {
        this.content.put(property, value);
    }

    /**
     * Method to get the value of a metadata.
     * @param property the name of the metadata
     * @return the value of the metadata
     */
    @Override
    public String getContentProperty(final String property) {
        return content.get(property);
    }

    /**
     * Method to get the names of the created metadata.
     * @return the names of the created metadata of this cathegory
     */
    @Override
    public String[] getContentPropertyNames() {
        String [] names = null;
        Iterator it = this.content.entrySet().iterator();
        int i = 0;
        while (it.hasNext()) {
            Map.Entry e = (Map.Entry) it.next();
            names[i] = (String) e.getKey();
            i++;
        }
        return names;
    }

    /**
     * Method to remove a metadata.
     * @param property the name of the metadata to remove
     */
    @Override
    public void removeContentProperty(final String property) {
        this.content.remove(property);
    }

    /**
     * Method to set a new metadata of the category "Intellectual Property".
     * @param property the name of the metadata
     * @param value the value of the metadata
     */
    @Override
    public void setIntellectualProperty(final String property,
            final String value) {
        this.intellectual.put(property, value);
    }

    /**
     * Method to get the value of a metadata.
     * @param property the name of the metadata
     * @return the value of the metadata
     */
    @Override
    public String getIntellectualProperty(final String property) {
        return this.intellectual.get(property);
    }

    /**
     * Method to get the names of the created metadata.
     * @return the names of the created metadata of this cathegory
     */
    @Override
    public String[] getIntellectualPropertyNames() {
        String [] names = null;
        Iterator it = this.intellectual.entrySet().iterator();
        int i = 0;
        while (it.hasNext()) {
            Map.Entry e = (Map.Entry) it.next();
            names[i] = (String) e.getKey();
            i++;
        }
        return names;
    }

    /**
     * Method to remove a metadata.
     * @param property the name of the metadata to remove
     */
    @Override
    public void removeIntellectualProperty(final String property) {
        this.intellectual.remove(property);
    }

    /**
     * Method to set a new metadata of the category "Instantiation".
     * @param property the name of the metadata
     * @param value the value of the metadata
     */
    @Override
    public void setInstantiationProperty(final String property,
            final String value) {
        this.instantiation.put(property, value);
    }

    /**
     * Method to get the value of a metadata.
     * @param property the name of the metadata
     * @return the value of the metadata
     */
    @Override
    public String getInstantiationProperty(final String property) {
        return this.instantiation.get(property);
    }

    /**
     * Method to get the names of the created metadata.
     * @return the names of the created metadata of this cathegory
     */
    @Override
    public String[] getInstantiationPropertyNames() {
        String [] names = null;
        Iterator it = this.instantiation.entrySet().iterator();
        int i = 0;
        while (it.hasNext()) {
            Map.Entry e = (Map.Entry) it.next();
            names[i] = (String) e.getKey();
            i++;
        }
        return names;
    }

    /**
     * Method to remove a metadata.
     * @param property the name of the metadata to remove
     */
    @Override
    public void removeInstantiationProperty(final String property) {
        this.instantiation.remove(property);
    }

}
